package cn.yunhe.servlet.FboardSboard;

import cn.yunhe.service.SboardService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/productSecondClass2ModifyServlet")
public class productSecondClass2ModifyServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //s1:参数接收

        String fbid2Str=request.getParameter("fbid");
        String sbid2Str=request.getParameter("sbid");
        String secondClassName=request.getParameter("secondClassName");
        System.out.println("<===fbid2Str====>"+fbid2Str);
        System.out.println("<===sbid2Str====>"+sbid2Str);
        System.out.println("<===secondClassName====>"+secondClassName);
        int fbid=Integer.parseInt(fbid2Str);
        int sbid=Integer.parseInt(sbid2Str);
        //s2:
        SboardService sboardService=new SboardService();
        //s3:
        Boolean flag=sboardService.updateSboard(sbid,secondClassName);

        if (flag){
            System.out.println("<===更新成功==>");
            response.sendRedirect("secondBoardListServlet");
        }else {
            System.out.println("<====更新失败====>");
            response.sendRedirect("productFirstClass-addSecondClass.jsp");
        }

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
